<?php

use think\facade\Route;


Route::rule("smscode","sms/code","post");
Route::resource('user', 'user');

//$where_waste['cid'] = session('cid');
//$where_waste['waste'] =1;
//$result_waste = M('user_company_rel')-> where($where_waste) -> find();
//if($result_waste){
//    $where_user['id'] = $result_waste['uid'];
//    $waste_user = M('user')-> where($where_user) -> find();
//}
//$office = M('office') ->where('cid='.session('cid').' AND is_waste=1 AND state=1') -> order('sort') -> select();
//$office_data = array();
//$office_sort = array();
//$max_line=0;
//if($office){
//    foreach ($office as $key => $value) {
//        # code...
//        $office_data[$value['name']] = $value['name'];
//        $office_sort[$value['name']] = $value['sort'];
//        if($value['sort'] > $max_line)
//        {
//            $max_line = $value['sort'];
//        }
//    }
//}
//
//// $office_data = array_values($office_data);
//$where_mounth['mounth'] = I('post.mounth');
//$where_mounth['cid'] = session('cid');
//$date_all = M('waste')->field('date')->group('date')->where($where_mounth)->select();
//import("Org.Util.PHPExcel");
//// 导出Exl
//import("Org.Util.PHPExcel");
//import("Org.Util.PHPExcel.Worksheet.Drawing");
//import("Org.Util.PHPExcel.Writer.Excel2007");
//$objPHPexcel = new PHPExcel();
//foreach ($date_all as $key => $value) {
//    $objSheet    = $objPHPexcel->setActiveSheetIndex($key);
//    $objPHPexcel->getActiveSheet()->setTitle($value['date']);
//    // $objPHPexcel->setActiveSheetIndex($key);
//    $date = I('post.mounth');
//    $where['mounth'] = $date;
//    $where['cid'] = session('cid');
//    $where['date'] = $value['date'];
//    $order_all = M('waste w')
//        ->join('join ser_user u on w.uid=u.id')
//        ->where($where)->select();
//    //获取当前活动sheet的操作对象
//    $objSheet->mergeCells('A1:K1');
//    $objSheet->getRowDimension(1)->setRowHeight(25.5);
//    $objSheet->setCellValue('A1', $order_all[0]['cname'].'周转场医疗废物收集表');
//    $objSheet->getStyle('A1')->getFont()->setSize(20);
//    $objSheet->getStyle('A1')->getFont()->setBold(true);
//    $objSheet->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    //合并单元格
//    $objSheet->mergeCells('H2:K2');
//    $objSheet->mergeCells('A3:A4');
//    $objSheet->mergeCells('B3:B4');
//    $objSheet->mergeCells('I3:I4');
//    $objSheet->mergeCells('J3:J4');
//    $objSheet->mergeCells('K3:K4');
//    $objSheet->mergeCells('C3:H3');
//    $objSheet->setCellValue('C3', '医疗废物日产生量（公斤）');
//    $objSheet->setCellValue('H2', '交接时间：'.$value['date']);
//    $objSheet->setCellValue('A3', '序号');
//    $objSheet->getStyle('A3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('A3')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//    $objSheet->getStyle('A3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('A3')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('B3', '医疗机构名称');
//    $objSheet->getStyle('B3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('B3')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('C4', 'HW01 831-001-01感染性废物');
//    $objSheet->getStyle('C4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('C4')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('D4', 'HW01 831-002-01损伤性废物');
//    $objSheet->getStyle('D4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('D4')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('E4', 'HW01 831-003-01病理性废物');
//    $objSheet->getStyle('E4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('E4')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('F4', 'HW01  831-004-01化学性废物');
//    $objSheet->getStyle('F4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('F4')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('G4', 'HW01 900-001-01为防治动物传染病而需要收集和处置的废物');
//    $objSheet->getStyle('G4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->getStyle('G4')->getAlignment()->setWrapText(true);
//    $objSheet->setCellValue('H4', '合计');
//    $objSheet->getStyle('H4')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//
//    $objSheet->setCellValue('I3', '医废产生单位人员签字');
//    $objSheet->getStyle('I3')->getAlignment()->setWrapText(true);
//    $objSheet->getStyle('I3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->setCellValue('J3', '周转场交接人员签字');
//    $objSheet->getStyle('J3')->getAlignment()->setWrapText(true);
//    $objSheet->getStyle('J3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    $objSheet->setCellValue('K3', '备注');
//    $objSheet->getStyle('K3')->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//    // 设置行高
//
//    $objSheet->getRowDimension(4)->setRowHeight(112.5);
//
//    $objSheet->getColumnDimension('A')->setWidth(6.63);
//    $objSheet->getColumnDimension('B')->setWidth(8.75);
//    $objSheet->getColumnDimension('C')->setWidth(8.63);
//    $objSheet->getColumnDimension('D')->setWidth(8.13);
//    $objSheet->getColumnDimension('E')->setWidth(8);
//    $objSheet->getColumnDimension('F')->setWidth(7.88);
//    $objSheet->getColumnDimension('G')->setWidth(8.63);
//    $objSheet->getColumnDimension('H')->setWidth(8);
//    $objSheet->getColumnDimension('I')->setWidth(7.88);
//    $objSheet->getColumnDimension('J')->setWidth(8.5);
//    $objSheet->getColumnDimension('K')->setWidth(7.88);
//
//
//    $tempOffice = $office_data;
//    $j = 5;
//    if ($order_all){
//        foreach ($order_all as $key => $val) {
//            $off_name = $tempOffice[$val['office']];
//            $line = $office_sort[$off_name]+4;
//            if(!$off_name){
//                continue;
//            }
//            $objSheet->setCellValue('A' . $line, $office_sort[$off_name])
//                ->setCellValue('B' . $line, $order_all[$j - 5]['office'])
//                ->setCellValue('C' . $line, $order_all[$j - 5]['hw_001'])
//                ->setCellValue('D' . $line, $order_all[$j - 5]['hw_002'])
//                ->setCellValue('E' . $line, $order_all[$j - 5]['hw_003'])
//                ->setCellValue('F' . $line, $order_all[$j - 5]['hw_004'])
//                ->setCellValue('G' . $line, $order_all[$j - 5]['hw_900'])
//                ->setCellValue('H' . $line, "=SUM(C$line:G$line)")
//                ->setCellValue('I' . $line, $order_all[$j - 5]['name'])
//                ->setCellValue('J' . $line, $waste_user['name'])
//                ->setCellValue('K' . $line, $order_all[$j - 5]['remarks']);
//            $objSheet->getStyle('A'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('A'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('A'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('B'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('B'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('B'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('C'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('C'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('C'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('D'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('D'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('D'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('E'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('E'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('E'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('F'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('F'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('F'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('G'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('G'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('G'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('H'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('H'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('H'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('I'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('I'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('J'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('J'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('J'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getStyle('K'.$line)->getAlignment()->setWrapText(true);
//            $objSheet->getStyle('K'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle('K'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $objSheet->getRowDimension($line)->setRowHeight(28.5);
//            $objSheet->getStyle("B$line")->getAlignment()->setWrapText(true);
//            $objSheet->getStyle("B$line")->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//            $objSheet->getStyle("B$line")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//            $j++;
//            unset($tempOffice[$val['office']]);
//        }
//
//        if($tempOffice){
//            foreach ($tempOffice as $key => $value) {
//                # code...
//                $line = $office_sort[$value]+4;
//                $objSheet->setCellValue('A' . $line, $office_sort[$value])
//                    ->setCellValue('B' . $line, $value);
//                $objSheet->getStyle('A'.$line)->getAlignment()->setWrapText(true);
//                $objSheet->getStyle('A'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//                $objSheet->getStyle('A'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//                $objSheet->getStyle('B'.$line)->getAlignment()->setWrapText(true);
//                $objSheet->getStyle('B'.$line)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//                $objSheet->getStyle('B'.$line)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//                $j++;
//            }
//        }
//
//        $styleArray = array(
//            'borders' => array(
//                'allborders' => array(
//                    //'style' => PHPExcel_Style_Border::BORDER_THICK,//边框是粗的
//                    'style' => \PHPExcel_Style_Border::BORDER_THIN,//细边框
//                    //'color' => array('argb' => 'FFFF0000'),
//                ),
//            ),
//        );
//
//        $j_1 = $max_line+4;
//        $j   = $max_line  + 6;
//        $objSheet->getStyle('A1:k'.$j)->applyFromArray($styleArray);
//        $objSheet->setCellValue('C'.$j,"=SUM(C5:C$j_1)")
//            ->setCellValue('D'.$j,"=SUM(D5:D$j_1)")
//            ->setCellValue('E'.$j,"=SUM(E5:E$j_1)")
//            ->setCellValue('F'.$j,"=SUM(F5:F$j_1)")
//            ->setCellValue('G'.$j,"=SUM(G5:G$j_1)")
//            ->setCellValue('H'.$j,"=SUM(H5:H$j_1)");
//        $objSheet->getStyle('C'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('C'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objSheet->getStyle('D'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('D'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objSheet->getStyle('E'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('E'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objSheet->getStyle('F'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('F'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objSheet->getStyle('G'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('G'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objSheet->getStyle('H'.$j)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
//        $objSheet->getStyle('H'.$j)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//        $objPHPexcel->createSheet();
//    }
//
//}
//// $sheet        = $objPHPexcel->getActiveSheet();
//// $sheet->getColumnDimension('A')->setWidth(13.22);
//$objweriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
//$Absolute_Path=$_SERVER['SCRIPT_FILENAME'];
//$path = substr($Absolute_Path,0,-9) . '/public';
//$objweriter->save($path . '/demo1.xlsx');
//$filename = date('Y-m-d H:i:s', time());
//$test=new \Org\Net\Http();
//return $test->download($path . '/demo1.xlsx', "$filename.xlsx");






